<?php

uses('sanitize');

$sanitize = new Sanitize();
$imgurl = '/img/strips/%02d.jpg';
$baseurl = '/strips/index/%d';
$id = $strip['Strip']['id'];

?>
<h1>
Strip #<?php echo $id; ?>: <?php echo $strip['Strip']['title']; ?>
</h1>
<div class="strip-image">
<img src="<?php echo $html->url(sprintf($imgurl, $id)); ?>" alt="<?php echo $strip['Strip']['title']; ?>" />
</div>
<div class="strip-nav">
<a href="<?php echo $html->url(sprintf($baseurl, 1)); ?>">&lt;&lt; First (1)</a> |
<?php if($id > 1) { ?>
<a href="<?php echo $html->url(sprintf($baseurl, $id - 1)); ?>">&lt; Previous (<?php echo $id - 1; ?>)</a> |
<?php } else { ?>
&lt; Previous (none) |
<?php } ?>
<a href="<?php echo $html->url('/strips/archive'); ?>">Archive</a> |
<?php if($isAdmin) { ?>
<a href="<?php echo $html->url('/strips/edit/' . $id); ?>">Edit</a> |
<?php } ?>
<a href="<?php echo $html->url(sprintf($baseurl, $id)); ?>">Permalink</a> |
<?php if($id < $lastid) { ?>
<a href="<?php echo $html->url(sprintf($baseurl, $id + 1)); ?>">Next (<?php echo $id + 1; ?>) &gt;</a> |
<?php } else { ?>
Next (none) &gt; |
<?php } ?>
<a href="<?php echo $html->url(sprintf($baseurl, $lastid)); ?>">Last (<?php echo $lastid; ?>) &gt;&gt;
</a>
</div>
<div class="strip-annotation">
<?php echo $bbcode->process($strip['Strip']['annotation']); ?>
</div>
<div class="strip-transcript">
<h2>Vision-Impaired Transcript</h2>
<?php echo $bbcode->process($strip['Strip']['transcript']); ?>
</div>
<div class="strip-comments">
<h2>Comments</h2>
<?php foreach($strip['Comment'] as $comment) { ?>
    <div class="strip-comment">
	<div class="comment-header">
	    <span class="openid-url"><?php echo $comment['Author']['name']; ?></span> posted at <span class="comment-date"><?php echo $comment['created']; ?></span>
	</div>
	<div class="comment-body">
	    <?php echo $bbcode->process($sanitize->html($comment['body'])); ?>
	</div>
    </div>
<?php } ?>
</div>
<div class="strip-comment-form">
    <?php if($loggedIn) {
    ?>
    <?php
	echo $form->create('Comment');
	echo $form->hidden('Comment.strip', array('value' => $id));
	echo $form->textarea('Comment.body', array('rows' => 10, 'cols' => 40));
	echo $form->submit('Post comment', array('class' => 'button'));
	echo $form->end();
     } else { ?>
        <p>
    	    You must be logged in with <a href="http://en.wikipedia.org/wiki/OpenID">OpenID</a> to post comments.
	    If you are a LiveJournal user, simply log in as <strong>yourname.livejournal.com</strong>.
	</p>
	<p>
	    No OpenID? <a href="http://getopenid.com">Get one now!</a>
	</p>
     <?php } ?>
</div>
